﻿import com.esri.ags.layers.LayerInfo;
import mx.controls.listClasses.BaseListData;

import com.uprr.app.tnm.events.*;
import com.uprr.app.tnm.model.*;
import mx.controls.*;
import mx.events.*;


private var _listData : BaseListData;

/*
[Bindable]
[Embed(source="/assets/combo_icon.png")]
private var comboIcon:Class;
*/

public function get listData () : BaseListData
{
	return _listData;
}
public function set listData (value : BaseListData) : void
{
	_listData = value;
}

private function clickHandler (event : MouseEvent) : void
{
	var layerInfo : LayerInfo = LayerInfo (data);
	if (event.target.selected)
	{
		layerInfo.defaultVisibility = true;
		LayerTOC (listData.owner).showLayer (layerInfo);
	} 
	else
	{
		layerInfo.defaultVisibility = false;
		LayerTOC (listData.owner).hideLayer (layerInfo);
	}
}


private function addLayerInfo():void{
	var layerInfo : LayerInfo = LayerInfo (data);
	if (layerInfo.subLayerIds==null){
		var checkBox:CheckBox=new CheckBox();
		checkBox.id='cb';
		checkBox.selected=data.defaultVisibility;
		checkBox.addEventListener(MouseEvent.CLICK, clickHandler);
		//this.addChild(checkBox);
	
		var label:Label=new Label();
		label.text=String(layerInfo.id);
		this.addChild(label);
	
		var image:Image=new Image();
		image.width=22;
		image.height=16;
		image.source=Model.getInstance().layerIcons.getItemAt(layerInfo.id);
		this.addChild(image);
	}
	
}


 